package com.lw.tem.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lw.tem.service.myservice.OrderService;
import com.lw.tem.service.temservice.handler.TemBlockHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sen")
public class SentinelTestController {
    @Autowired
    private OrderService orderService;
    @GetMapping("/quick")
    @SentinelResource(value = "com.lw.tem.controller.SentinelTestController:quick(void)", blockHandlerClass = TemBlockHandler.class, blockHandler = "handleQuickBlock")
    public String quick() {
        return "passed_quick";
    }
    @GetMapping("/quick1")
    @SentinelResource(value = "sen.quick1", blockHandlerClass = TemBlockHandler.class, blockHandler = "handleQuickBlock")
    public String quick1() {
        return "passed_quick1";
    }
    @GetMapping("/quick2")
    @SentinelResource(value = "sen.quick2", blockHandlerClass = TemBlockHandler.class, blockHandler = "handleQuickBlock")
    public String quick2() {
        return "passed_quick2  "+orderService.createOrder();
    }
    @GetMapping("/quick3")
    @SentinelResource(value = "sen.quick3", blockHandlerClass = TemBlockHandler.class, blockHandler = "handleQuickBlock")
    public String quick3() {
        return "passed_quick3  "+orderService.createOrder();
    }

}
